import 'package:flutter/material.dart';

class RowTest extends StatelessWidget {
  const RowTest({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter layout demo',
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter layout demo'),
        ),
        // Change to buildColumn() for the other column example
        body: ListView(
          children: [
            const Text("MainAxisAlignment.start"),
            buildRow(MainAxisAlignment.start),
            const Text("MainAxisAlignment.end"),
            buildRow(MainAxisAlignment.end),
            const Text("MainAxisAlignment.center"),
            buildRow(MainAxisAlignment.center),
            const Text("MainAxisAlignment.spaceBetween"),
            buildRow(MainAxisAlignment.spaceBetween),
            const Text("MainAxisAlignment.spaceAround"),
            buildRow(MainAxisAlignment.spaceAround),
            const Text("MainAxisAlignment.spaceEvenly"),
            buildRow(MainAxisAlignment.spaceEvenly),
            buildStarRow()
          ],
        ),
      ),
    );
  }

  Widget buildStarRow() {
    return Row(
      //行或列沿其主轴会占用尽可能多的空间，但如果要将子项紧密组合在一起，请将其 mainAxisSize 设置为 MainAxisSize.min
      mainAxisSize: MainAxisSize.min,
      children: [
        Icon(Icons.star, color: Colors.green[300]),
        Icon(Icons.star, color: Colors.green[400]),
        Icon(Icons.star, color: Colors.green[500]),
        const Icon(Icons.star, color: Colors.black),
        const Icon(Icons.star, color: Colors.black),
      ],
    );
  }

  Widget buildRow(MainAxisAlignment mainAxisAlignment) =>
      // #docregion Row
      Row(
        mainAxisAlignment: mainAxisAlignment,
        children: [
          Image.asset('images/pic1.jpg'),
          Image.asset('images/pic2.jpg'),
          Image.asset('images/pic3.jpg'),
        ],
      );
// #enddocregion Row
}
